package com.qffx.moviebase.presenter;

import android.content.Context;
import android.util.Log;

import com.qffx.moviebase.bean.find.FindNewestEntity;
import com.qffx.moviebase.model.FindNewestModel;
import com.qffx.moviebase.model.impl.FindNewestM;
import com.qffx.moviebase.presenter.impl.BasePresenter;
import com.qffx.moviebase.view.impl.FindNewestView;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by lx on 2017/2/8.
 */

public class FindNewestPresenter implements BasePresenter{

    private FindNewestM model;
    private FindNewestView view;
    private Context context;

    public FindNewestPresenter(FindNewestView view, Context context) {
        model=new FindNewestModel();
        this.view = view;
        this.context = context;
    }


    public void getData(int index) {
        Observable<FindNewestEntity> observable=model.loadInfo(index);
        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<FindNewestEntity>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(FindNewestEntity entity) {
                        view.setDate(entity);
                    }
                });
    }


    @Override
    public void getData() {

    }
}
